home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Utilities / vim-5.1 / doc / eval.txt < prev    next >
Encoding:
Text File  |  1998-04-06  |  32.9 KB  |  944 lines

  1. *eval.txt*      For Vim version 5.1.  Last modification: 1998 Apr 06
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Expression evaluation                    *expression* *expr*
  8.  
  9. Note: Expression evaluation can be disabled at compile time.  If this has been
  10. done, the features in this document are not available.  See |+eval|.
  11.  
  12. 1. Variables        |variables|
  13. 2. Expression syntax    |expression-syntax|
  14. 3. Internal variable    |internal-variables|
  15. 4. Function calls    |functions|
  16. 5. Commands        |expression-commands|
  17.  
  18. {Vi does not have any of these commands}
  19.  
  20. ==============================================================================
  21. 1. Variables                        *variables*
  22.  
  23. There are two types of variables:
  24.  
  25. Number        a 32 bit signed number
  26. String        a NUL terminated string of 8-bit unsigned characters.
  27.  
  28. These are converted automatically, depending on how they are used.
  29.  
  30. Conversion from a Number to a String is by making the ASCII representation of
  31. the Number.  Examples:
  32. >    Number 123    -->    String "123"
  33. >    Number 0    -->    String "0"
  34. >    Number -1    -->    String "-1"
  35.  
  36. Conversion from a String to a Number is done by converting the first digits
  37. to a number.  Hexadecimal "0xf9" and Octal "017" numbers are recognized.  If
  38. the String doesn't start with digits, the result is zero.  Examples:
  39. >    String "456"    -->    Number 456
  40. >    String "6bar"    -->    Number 6
  41. >    String "foo"    -->    Number 0
  42. >    String "0xf1"    -->    Number 241
  43. >    String "0100"    -->    Number 64
  44.  
  45. For boolean operators Numbers are used.  Zero is FALSE, non-zero is TRUE.
  46.  
  47. Note that in the command
  48.     :if "foo"
  49. "foo" is converted to 0, which means FALSE.  To test for a non-empty string,
  50. use strlen():
  51.     :if strlen("foo")
  52.  
  53. ==============================================================================
  54. 2. Expression syntax                    *expression-syntax*
  55.  
  56. Expression syntax summary, from least to most significant:
  57.  
  58. |expr1|    expr2 || expr2 ..    logical OR
  59.  
  60. |expr2|    expr3 && expr3 ..    logical AND
  61.  
  62. |expr3|    expr4 == expr4        equal
  63.     expr4 != expr4        not equal
  64.     expr4 >     expr4        greater than
  65.     expr4 >= expr4        greater than or equal
  66.     expr4 <     expr4        smaller than
  67.     expr4 <= expr4        smaller than or equal
  68.     expr4 =~ expr4        regexp matches
  69.     expr4 !~ expr4        regexp doesn't match
  70.  
  71. |expr4|    expr5 +     expr5 ..    number addition
  72.     expr5 -     expr5 ..    number subtraction
  73.     expr5 .     expr5 ..    string concatenation
  74.  
  75. |expr5|    expr6 *     expr6 ..    number multiplication
  76.     expr6 /     expr6 ..    number division
  77.     expr6 %     expr6 ..    number modulo
  78.  
  79. |expr6|    ! expr6            logical NOT
  80.     - expr6            unary minus
  81.  
  82. |expr7|    expr8[expr1]        index in String
  83.  
  84. |expr8|    number            number constant
  85.     "string"        string constant
  86.     'string'        literal string constant
  87.     &option            option value
  88.     (expr1)            nested expression
  89.     variable        internal variable
  90.     $VAR            environment variable
  91.     @r            contents of register 'r'
  92.     function(expr1, expr1)    function call
  93.  
  94. ".." indicates that the operations in this level can be concatenated.
  95. Example:
  96. >    &nu || &list && &shell == "csh"
  97.  
  98. All expressions within one level are parsed from left to right.
  99.  
  100.  
  101. expr1 and expr2                        *expr1* *expr2*
  102. ---------------
  103.  
  104.                         *expr-barbar* *expr-&&*
  105. The "||" and "&&" operators take one argument on each side.  The arguments
  106. are (converted to) Numbers.  The result is:
  107.  
  108.          input                 output            ~
  109.     n1        n2        n1 || n2    n1 && n2    ~
  110.     zero    zero        zero        zero
  111.     zero    non-zero    non-zero    zero
  112.     non-zero    zero        non-zero    zero
  113.     non-zero    non-zero    non-zero    non-zero
  114.  
  115. The operators can be concatenated, for example:
  116.  
  117. >    &nu || &list && &shell == "csh"
  118.  
  119. Note that "&&" takes precedence over "||", so this has the meaning of:
  120.  
  121. >    &nu || (&list && &shell == "csh")
  122.  
  123. All arguments are computed, there is no skipping if the value of an argument
  124. doesn't matter, because the result is already known.  This is different from
  125. C, although it only matters for errors (unknown variables), since there are no
  126. side effects from an expression.
  127.  
  128.  
  129. expr3                            *expr3*
  130. -----
  131.     expr4 == expr4        equal            *expr-==*
  132.     expr4 != expr4        not equal        *expr-!=*
  133.     expr4 >     expr4        greater than        *expr->*
  134.     expr4 >= expr4        greater than or equal    *expr->=*
  135.     expr4 <     expr4        smaller than        *expr-<*
  136.     expr4 <= expr4        smaller than or equal    *expr-<=*
  137.     expr4 =~ expr4        regexp matches        *expr-=~*
  138.     expr4 !~ expr4        regexp doesn't match    *expr-!~*
  139.  
  140. When comparing a String with a Number, the String is converted to a Number,
  141. and the comparison is done on Numbers.
  142.  
  143. When comparing two Strings, this is done with strcmp().  This results in the
  144. mathematical difference, not necessarily the alphabetical difference in the
  145. local language.
  146.  
  147. The "=~" and "!~" operators match the lefthand argument with the righthand
  148. argument, which is used as a pattern.  See |pattern| for what a pattern is.
  149. This matching is always done like 'magic' was set, no matter what the actual
  150. value of 'magic' is.  This makes scripts portable.  The value of 'ignorecase'
  151. does matter though.  To avoid backslashes in the regexp pattern to be doubled,
  152. use a single-quote string, see |literal-string|.
  153.  
  154.  
  155. expr4 and expr5                        *expr4* *expr5*
  156. ---------------
  157.     expr5 +     expr5 ..    number addition        *expr-+*
  158.     expr5 -     expr5 ..    number subtraction    *expr--*
  159.     expr5 .     expr5 ..    string concatenation    *expr-.*
  160.  
  161.     expr6 *     expr6 ..    number multiplication    *expr-star*
  162.     expr6 /     expr6 ..    number division        *expr-/*
  163.     expr6 %     expr6 ..    number modulo        *expr-%*
  164.  
  165. For all, except ".", Strings are converted to Numbers.
  166.  
  167. Note the difference between "+" and ".":
  168.     "123" + "456" = 579
  169.     "123" . "456" = "123456"
  170.  
  171. When the righthand side of '/' is zero, the result is 0xfffffff.
  172. When the righthand side of '%' is zero, the result is 0.
  173.  
  174.  
  175. expr6                            *expr6*
  176. -----
  177.     ! expr6            logical NOT        *expr-!*
  178.     - expr6            unary minus        *expr-unary--*
  179.  
  180. For '!' non-zero becomes zero, zero becomes one.
  181. For '-' the sign of the number is changed.
  182.  
  183. A String will be converted to a Number first.
  184.  
  185. These two can be repeated and mixed.  Examples:
  186.     !-1        == 0
  187.     !!8        == 1
  188.     --9        == 9
  189.  
  190.  
  191. expr7                            *expr7*
  192. -----
  193.     expr8[expr1]        index in String        *expr-[]*
  194.  
  195. This results in a String that contains the expr1'th single character from
  196. expr8.  expr8 is used as a String, expr1 as a Number.
  197.  
  198. Note that index zero gives the first character.  This is like it works in C.
  199. Careful: column numbers start with one!  Example, to get the character under
  200. the cursor:
  201. >   c = getline(line("."))[col(".") - 1]
  202.  
  203. If the length of the String is less than the index, the result is an empty
  204. String.
  205.  
  206.                             *expr8*
  207. number
  208. ------
  209.     number            number constant        *expr-number*
  210.  
  211. Decimal, Hexadecimal (starting with 0x or 0X), or Octal (starting with 0).
  212.  
  213.  
  214. string                            *expr-string*
  215. ------
  216.     "string"        string constant        *expr-quote*
  217.  
  218. Note that double quotes are used.
  219.  
  220. A string constant accepts these special characters:
  221.     \...    three-digit octal number (e.g., "\316")
  222.     \..    two-digit octal number (must be followed by non-digit)
  223.     \.    one-digit octal number (must be followed by non-digit)
  224.     \x..    two-character hex number (e.g., "\x1f")
  225.     \x.    one-character hex number (must be followed by non-hex)
  226.     \X..    same as \x..
  227.     \X.    same as \x.
  228.     \b    backspace <BS>
  229.     \e    escape <Esc>
  230.     \f    formfeed <FF>
  231.     \n    newline <NL>
  232.     \r    return <CR>
  233.     \t    tab <Tab>
  234.     \\    backslash
  235.     \"    double quote
  236.     \<xxx>    Special key named "xxx".  e.g. "\<C-W>" for CTRL-W.
  237.  
  238. Note that "\000" and "\x00" force the end of the string.
  239.  
  240.  
  241. literal-string                        *literal-string*
  242. ---------------
  243.     'string'        literal string constant        *expr-'*
  244.  
  245. Note that single quotes are used.
  246.  
  247. This string is taken literally.  No backslashes are removed or have a special
  248. meaning.  A literal-string cannot contain a single quote.  Use a normal string
  249. for that.
  250.  
  251.  
  252. option                            *expr-option*
  253. ------
  254.     &option            option value
  255.  
  256. Any option name can be used here.  See |options|.
  257.  
  258.  
  259. register                        *expr-register*
  260. --------
  261.     @r            contents of register 'r'
  262.  
  263. The result is the contents of the named register, as a single string.
  264. Newlines are inserted where required.  To get the contents of the unnamed
  265. register use @@.  The '=' register can not be used here.  See |registers| for
  266. an explanation of the available registers.
  267.  
  268.  
  269. nesting                            *expr-nesting*
  270. -------
  271.     (expr1)            nested expression
  272.  
  273.  
  274. environment variable                    *expr-env*
  275. --------------------
  276.     $VAR            environment variable
  277.  
  278. The String value of any environment variable.  When it is not defined, the
  279. result is an empty string.
  280.  
  281.  
  282. internal variable                    *expr-variable*
  283. -----------------
  284.     variable        internal variable
  285. See below |internal-variables|.
  286.  
  287.  
  288. function call                        *expr-function*
  289. -------------
  290.     function(expr1, expr1)    function call
  291. See below |functions|.
  292.  
  293.  
  294. ==============================================================================
  295. 3. Internal variable                    *internal-variables*
  296.  
  297. An internal variable name can be made up of letters, digits and '_'.  But it
  298. cannot start with a digit.
  299.  
  300. An internal variable is created with the ":let" command |:let|.
  301. An internal variable is destroyed with the ":unlet" command |:unlet|.
  302. Using a name that isn't an internal variable, or an internal variable that has
  303. been destroyed, results in an error.
  304.  
  305. A variable name that is preceded with "b:" is local to the current buffer.
  306. A variable name that is preceded with "w:" is local to the current window.
  307.  
  308. Predefined variables:
  309.                             *count-variable*
  310. count        The count given for the last Normal mode command.  Can be used
  311.         to get the count before a mapping.  Example:
  312. >    :map _x :<C-U>echo "the count is " . count<CR>
  313.         Note: The <C-U> is required to remove the line range that you
  314.         get when typing ':' after a count.  read-only.
  315.  
  316.                             *errmsg-variable*
  317. errmsg        Last given error message.  It's allowed to set this variable.
  318.         Example:
  319. >    :let errmsg = ""
  320. >    :next
  321. >    :if (errmsg != "")
  322. >    :  ...
  323.  
  324.                             *shell_error-variable*
  325. shell_error    Result of the last shell command.  When non-zero, the last
  326.         shell command had an error.  When zero, there was no problem.
  327.         This only works when the shell returns the error code to Vim.
  328.         Example:
  329. >    :!mv foo bar
  330. >    :if shell_error
  331. >    :  echo 'could not rename "foo" to "bar"!'
  332. >    :endif
  333.  
  334.                             *version-variable*
  335. version        Version number of Vim: Major version number times 100 plus
  336.         minor version number.  Version 5.0 is 500.  Version 5.1 (5.01)
  337.         is 501.  Read-only.
  338.  
  339. ==============================================================================
  340. 4. Function calls                        *functions*
  341.  
  342. USAGE                RESULT    DESCRIPTION    ~
  343.  
  344. buffer_exists({expr})        Number    TRUE if a buffer {exp} exists
  345. buffer_name({expr})        String    Name of the buffer {expr}
  346. buffer_number({expr})        Number    Number of the buffer {expr}
  347. char2nr({expr})            Number  ASCII value of first char in {expr}
  348. col({expr})            Number    column nr of cursor or mark
  349. delete({expr})            Number    delete file {expr}
  350. exists({var})            Number    TRUE if {var} exists
  351. expand({expr})            String    expand file wildcards in {expr}
  352. file_readable({file})        Number    TRUE if {file} is a readable file
  353. getcwd()            String  the current working directory
  354. getline({lnum})            String    line {lnum} from current buffer
  355. has({feature})            Number    TRUE if feature {feature} supported
  356. highlight_exists({name})    Number    TRUE if highlight group {name} exists
  357. highlightID({name})        Number  syntax ID of highlight group {name}
  358. hostname()            String    name of the machine vim is running on
  359. isdirectory({directory})    Number    TRUE if {directory} is a directory
  360. last_buffer_nr()        Number    buffer number of last buffer
  361. line({expr})            Number    line nr of cursor, last line or mark
  362. match({expr}, {pat})        Number    position where {pat} matches in {expr}
  363. matchend({expr}, {pat})        Number    position where {pat} ends in {expr}
  364. nr2char({expr})            String    single char with ASCII value {expr}
  365. strftime({expr})        String    current time in specified format
  366. strlen({expr})            Number    length of the String {expr}
  367. strpart({src}, {start}, {len})    String    {len} characters of {src} at {start}
  368. synID({line}, {col}, {trans})    Number  syntax ID at {line} and {col}
  369. synIDattr({synID}, {what})    String  attribute {what} of syntax ID {synID}
  370. synIDtrans({synID})        Number  translated syntax ID of {synID}
  371. substitute({expr}, {pat}, {sub}, {flags})
  372.                 String    all {pat} in {expr} replaced with {sub}
  373. tempname()            String    name for a temporary file
  374. virtcol({expr})            Number    screen column of cursor or mark
  375. winheight({nr})            Number    height of window {nr}
  376.  
  377.                             *buffer_exists()*
  378. buffer_exists({var})
  379.         The result is a Number, which is non-zero if a buffer called
  380.         {var} exists.  If the {var} argument is a string it must match
  381.         a buffer name exactly.  If the {var} argument is a number
  382.         buffer numbers are used.  Use "buffer_exists(0)" to test for
  383.         the existence of an alternate file name.
  384.  
  385.                             *buffer_name()*
  386. buffer_name({expr})
  387.         The result is the name of a buffer, as it is displayed by the
  388.         ":ls" command.
  389.         If {expr} is a number, that buffer number's name is given.
  390.         Number zero is the alternate buffer for the current window.
  391.         If {expr} is a string, it is used as a regexp pattern to match
  392.         with the buffer names.  When there is more than one match an
  393.         empty string is returned.  "" or "%" can be used for the
  394.         current buffer, "#" for the alternate buffer.
  395.         If the buffer doesn't exist, or doesn't have a name, an empty
  396.         string is returned.
  397. >  buffer_name("#")        alternate buffer name
  398. >  buffer_name(3)        name of buffer 3
  399. >  buffer_name("%")        name of current buffer
  400. >  buffer_name("file2")        name of buffer where "file2" matches.
  401.  
  402.                             *buffer_number()*
  403. buffer_number({expr})
  404.         The result is the number of a buffer, as it is displayed by
  405.         the ":ls" command.  For the use of {expr}, see buffer_name()
  406.         above.
  407.         If the buffer doesn't exist, -1 is returned.
  408.  
  409.                             *char2nr()*
  410. char2nr({expr})
  411.         Return ASCII value of the first char in {expr}.  Examples:
  412. >            char2nr(" ")        returns 32
  413. >            char2nr("ABC")        returns 65
  414.  
  415.                             *col()*
  416. col({expr})    The result is a Number, which is the column of the file
  417.         position given with {expr}.  The accepted positions are:
  418.             .        the cursor position
  419.             'x        position of mark x (if the mark is not set, 0 is
  420.                 returned)
  421.         Note that only marks in the current file can be used.
  422.         Examples:
  423. >            col(".")        column of cursor
  424. >            col("'t")        column of mark t
  425. >            col("'" . markname)    column of mark markname
  426.         The first column is 1.  0 is returned for an error.
  427.  
  428.                             *delete()*
  429. delete({expr})    Deletes the file by the name {expr}.  The result is a Number,
  430.         which is 0 if the file was deleted succesfully, and non-zero
  431.         when the deletion failed.
  432.  
  433.                             *exists()*
  434. exists({expr})    The result is a Number, which is 1 if {var} is defined, zero
  435.         otherwise.  The {expr} argument is a string, which contains
  436.         one of these:
  437.             &option-name      Vim option
  438.             $ENVNAME      environment variable (could also be
  439.                       done by comparing with an empty
  440.                       string)
  441.             varname          internal variable (see
  442.                       |internal-variables|).
  443.  
  444.         Examples:
  445. >            exists("&shortname")
  446. >            exists("$HOSTNAME")
  447. >            exists("bufcount")
  448.         Note that the argument must be a string, not the name of the
  449.         variable itself!  This doesn't check for existence of the
  450.         "bufcount" variable, but gets the contents of "bufcount", and
  451.         checks if that exists:
  452.             exists(bufcount)
  453.  
  454.                             *expand()*
  455. expand({expr})    Expand the file wildcards in {expr}.  The result is a String.
  456.         When there are several matches, they are separated by <NL>
  457.         characters.  [Note: in version 5.0 a space was used, which
  458.         caused problems when a file name contains a space]
  459.         For Unix, backticks can be used to get the output of any
  460.         command.  Example:
  461. >            :let tagfiles = expand("`find . -name tags -print`")
  462. >            :let &tags = substitute(tagfiles, "\n", ",", "g")
  463.  
  464.         If the expansion fails, the result is an empty string.
  465.  
  466.         When the result of {expr} starts with '%', '#' or '<', the
  467.         expansion is done like for the |cmdline-special| variables
  468.         with their associated modifiers.  Here is a short overview:
  469.  
  470.         %            current file name
  471.         #            alternate file name
  472.         #n            alternate file name n
  473.         <cfile>            file name under the cursor
  474.         <afile>            autocmd file name
  475.         <sfile>            sourced script file name
  476.         <cword>            word under the cursor
  477.         <cWORD>            WORD under the cursor
  478.     Modifiers:
  479.         :p            expand to full path
  480.         :h            head (last path component removed)
  481.         :t            tail (last path component only)
  482.         :r            root (one extension removed)
  483.         :e            extension only
  484.  
  485.         Example:
  486. >            :let &tags = expand("%:p:h") . "/tags"
  487.  
  488.         There cannot be white space between the variables and the
  489.         following modifier.
  490.  
  491.         When using '%' or '#', and the current or alternate file name
  492.         is not defined, an empty string is used.  Using "%:p" in a
  493.         buffer with no name, results in the current directory, with a
  494.         '/' added.
  495.  
  496.                             *file_readable()*
  497. file_readable({file})
  498.         The result is a Number, which is TRUE when a file with the
  499.         name {file} exists, and can be read.  If {file} doesn't exist,
  500.         or is a directory, the result is FALSE.  {file} is any
  501.         expression, which is used as a String.
  502.  
  503.                             *getcwd()*
  504. getcwd()        The result is a String, which is the name of the current
  505.         working directory.
  506.  
  507.                             *getline()*
  508. getline({lnum}) The result is a String, which is line {lnum} from the current
  509.         buffer.  Example:
  510. >            getline(1)
  511.         When {lnum} is a String that doesn't start with a
  512.         digit, line() is called to translate the String into a Number.
  513.         To get the line under the cursor:
  514. >            getline(".")
  515.         When {lnum} is smaller than 1 or bigger than the number of
  516.         lines in the buffer, an empty string is returned.
  517.  
  518.                             *has()*
  519. has({feature})    The result is a Number, which is 1 if the feature {feature} is
  520.         supported, zero otherwise.  The {feature} argument is a
  521.         string.  See |feature-list| below.
  522.  
  523.                             *highlight_exists()*
  524. highlight_exists({name})
  525.         The result is a Number, which is non-zero if a highlight group
  526.         called {name} exists.  This is when the group has been
  527.         defined in some way.  Not necessarily when highlighting has
  528.         been defined for it, it may also have been used for a syntax
  529.         item.
  530.  
  531.                             *highlightID()*
  532. highlightID({name})
  533.         The result is a Number, which is the ID of the highlight group
  534.         with name {name}.  When the highlight group doesn't exist,
  535.         zero is returned.
  536.         This can be used to retrieve information about the highlight
  537.         group.  For example, to get the background color of the
  538.         "Comment" group:
  539. >    echo synIDattr(synIDtrans(highlightID("Comment")), "bg")
  540.  
  541.                             *hostname()*
  542. hostname()
  543.         The result is a String, which is the name of the machine on
  544.         which Vim is currently running. Machine names greater than
  545.         256 characters long are truncated.
  546.  
  547.                             *isdirectory()*
  548. isdirectory({directory})
  549.         The result is a Number, which is TRUE when a directory with
  550.         the name {directory} exists.  If {directory} doesn't exist, or
  551.         isn't a directory, the result is FALSE.  {directory} is any
  552.         expression, which is used as a String.
  553.  
  554.                             *last_buffer_nr()*
  555. last_buffer_nr()
  556.         The result is a Number, which is the highest buffer number
  557.         of existing buffers.  Note that not all buffers with a smaller
  558.         number necessarily exist, because ":bdel" may have removed
  559.         them.  Use buffer_exists() to test for the existence of a
  560.         buffer.
  561.                             *line()*
  562. line({expr})    The result is a Number, which is the line number of the file
  563.         position given with {expr}.  The accepted positions are:
  564.             .        the cursor position
  565.             $        the last line in the current buffer
  566.             'x        position of mark x (if the mark is not set, 0 is
  567.                 returned)
  568.         Note that only marks in the current file can be used.
  569.         Examples:
  570. >            line(".")        line number of the cursor
  571. >            line("'t")        line number of mark t
  572. >            line("'" . marker)    line number of mark marker
  573.  
  574.                             *strftime()*
  575. strftime({format})
  576.         The result is a String, which is the current date and time, as
  577.         specified by the {format} string.  See the manual page of the
  578.         C function strftime() for the format.  The maximum length of
  579.         the result is 80 characters.  Examples:
  580. >          :echo strftime("%c")           Sun Apr 27 11:49:23 1997
  581. >          :echo strftime("%Y %b %d %X")       1997 Apr 27 11:53:25
  582. >          :echo strftime("%y%m%d %T")       970427 11:53:55
  583. >          :echo strftime("%H:%M")       11:55
  584.  
  585.                             *match()*
  586. match({expr}, {pat})
  587.         The result is a Number, which gives the index in {expr} where
  588.         {pat} matches.  A match at the first character returns zero.
  589.         If there is no match -1 is returned.  Example:
  590. >            :echo match("testing", "ing")
  591.         results in "4".
  592.         See |pattern| for the patterns that are accepted.
  593.  
  594.                             *matchend()*
  595. matchend({expr}, {pat})
  596.         Same as match(), but return the index of first character after
  597.         the match.  Example:
  598. >            :echo matchend("testing", "ing")
  599.         results in "7".
  600.  
  601.                             *nr2char()*
  602. nr2char({expr})
  603.         Return a string with a single chararacter, which has the ASCII
  604.         value {expr}.  Examples:
  605. >            nr2char(64)        returns "@"
  606. >            nr2char(32)        returns " "
  607.  
  608.                             *strlen()*
  609. strlen({expr})    The result is a Number, which is the length of the String
  610.         {expr}.
  611.  
  612.                             *strpart()*
  613. strpart({src}, {start}, {len})
  614.         The result is a String, which is part of {src},
  615.         starting from character {start}, with the length {len}.
  616.         When non-existing characters are included, this doesn't result
  617.         in an error, the characters are simply omitted.
  618. >            strpart("abcdefg", 3, 2)    == "de"
  619. >            strpart("abcdefg", -2, 4)   == "ab"
  620. >            strpart("abcdefg", 5, 4)    == "fg"
  621.         Note: To get the first character, {start} must be 0.  For
  622.         example, to get three characters under and after the cursor:
  623. >            strpart(getline(line(".")), col(".") - 1, 3)
  624.  
  625.                             *synID()*
  626. synID({line}, {col}, {trans})
  627.         The result is a Number, which is the syntax ID at the position
  628.         {line} and {col} in the current window.
  629.         The syntax ID can be used with |synIDattr()| and
  630.         |synIDtrans()| to obtain syntax information about text.
  631.         {col} is 1 for the leftmost column, {line} is 1 for the first
  632.         line.
  633.         When {trans} is non-zero, transparant items are reduced to the
  634.         item that they reveal.  This is useful when wanting to know
  635.         the effective color.  When {trans} is zero, the transparant
  636.         item is returned.  This is useful when wanting to know which
  637.         syntax item is effective (e.g. inside parens).
  638.         Warning: This function can be very slow.  Best speed is
  639.         obtained by going through the file in forward direction.
  640.  
  641.         Example (echos the name of the syntax item under the cursor):
  642. >            :echo synIDattr(synID(line("."), col("."), 1), "name")
  643.  
  644.                             *synIDattr()*
  645. synIDattr({synID}, {what})
  646.         The result is a String, which is the {what} attribute of
  647.         syntax ID {synID}.  This can be used to obtain information
  648.         about a syntax item.
  649.         The attributes for the currently active highlighting are used
  650.         (GUI, cterm or term).
  651.         Use synIDtrans() to follow linked highlight groups.
  652.         {what}        result
  653.         "name"        the name of the syntax item
  654.         "fg"        foreground color (GUI: color name, cterm:
  655.                 color number as a string, term: empty string)
  656.         "bg"        background color (like "fg")
  657.         "fg#"        like "fg", but name in "#RRGGBB" form
  658.         "bg#"        like "bg", but name in "#RRGGBB" form
  659.         "bold"        "1" if bold
  660.         "italic"    "1" if italic
  661.         "reverse"    "1" if reverse
  662.         "inverse"    "1" if inverse (= reverse)
  663.         "underline"    "1" if underlined
  664.  
  665.         Example (echos the color of the syntax item under the cursor):
  666. >    :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  667.  
  668.                             *synIDtrans()*
  669. synIDtrans({synID})
  670.         The result is a Number, which is the translated syntax ID of
  671.         {synID}.  This is the syntax group ID of what is being used to
  672.         highlight the character.  Highlight links are followed.
  673.  
  674.                             *substitute()*
  675. substitute({expr}, {pat}, {sub}, {flags})
  676.         The result is a String, which is a copy of {expr}, in which
  677.         the first match of {pat} is replaced with {sub}.  This works
  678.         like the ":substitute" command (without any flags).
  679.         When {pat} does not match in {expr}, {expr} is returned
  680.         unmodified.
  681.         When {flags} is "g", all matches of {pat} in {expr} are
  682.         replaced.  Otherwise {flags} should be "".
  683.         Example:
  684. >            :let &path = substitute(&path, ",\\=[^,]*$", "", "")
  685.         This removes the last component of the 'path' option.
  686. >            :echo substitute("testing", ".*", "\\U\\0", "")
  687.         results in "TESTING".
  688.  
  689.                             *tempname()*
  690. tempname()
  691.         The result is a String, which is the name of a file that
  692.         doesn't exist.  It can be used for a temporary file.  The name
  693.         is different for each least 26 consecutive calls.  Example:
  694. >            let tmpfile = tempname()
  695. >            exe "redir > " . tmpfile
  696.  
  697.                             *virtcol()*
  698. virtcol({expr})
  699.         The result is a Number, which is the screen column of the file
  700.         position given with {expr}.  That is, the last screen position
  701.         occupied by the character at that position, when the screen
  702.         would be of unlimited width.  When there is a <Tab> at the
  703.         position, the returned Number will be the column at the end of
  704.         the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
  705.         set to 8, it returns 8;
  706.         The accepted positions are:
  707.             .        the cursor position
  708.             'x        position of mark x (if the mark is not set, 0 is
  709.                 returned)
  710.         Note that only marks in the current file can be used.
  711.         Examples:
  712. >  virtcol(".")        with text "foo^Lbar", with cursor on the "^L", returns 5
  713. >  virtcol("'t")    with text "    there", with 't at 'h', returns 6
  714.         The first column is 1.  0 is returned for an error.
  715.  
  716.                             *winheight()*
  717. winheight({nr})
  718.         The result is a Number, which is the height of window {nr}.
  719.         When {nr} is zero, the height of the current window is
  720.         returned.  When window {nr} doesn't exist, zero is returned.
  721.         An existing window always has a height of one or more.
  722.         Examples:
  723. >  echo "The current window has " . winheight(0) . " lines."
  724.  
  725.  
  726.                             *feature-list*
  727. There are two types of features:
  728. 1.  Features that are only supported when they have been enabled when Vim
  729.     was compiled |+feature-list|.  Example:
  730. >        :if has("cindent")
  731. 2.  Features that are only supported when certain conditions have been met.
  732.     Example:
  733. >        :if has("gui_running")
  734.  
  735. all_builtin_terms    Compiled with all builtin terminals enabled.
  736. amiga            Amiga version of Vim.
  737. arp            Compiled with ARP support (Amiga).
  738. autocmd            Complied with autocommands support.
  739. beos            BeOS version of Vim.
  740. builtin_terms        Compiled with some builtin terminals.
  741. cindent            Compiled with 'cindent' support.
  742. compatible        Compiled to be very Vi compatible.
  743. debug            Compiled with "DEBUG" defined.
  744. digraphs        Compiled with support for digraphs.
  745. dos32            32 bits DOS (DJGPP) version of Vim.
  746. dos16            16 bits DOS version of Vim.
  747. emacs_tags        Compiled with support for Emacs tags.
  748. eval            Compiled with exression evaluation support.  Always
  749.             true, of course!
  750. ex_extra        Compiled with extra Ex commands |+ex_extra|.
  751. extra_search        Compiled with support for |'incsearch'| and
  752.             |'hlsearch'|
  753. farsi            Compiled with Farsi support |farsi|.
  754. file_in_path        Compiled with support for |gf| and |<cfile>|
  755. find_in_path        Compiled with support for include file searches
  756.             |+find_in_path|.
  757. fname_case        Case in file names matters (for Amiga, MS-DOS, and
  758.             Windows this is not present).
  759. fork            Compiled to use fork()/exec() instead of system().
  760. gui            Compiled with GUI enabled.
  761. gui_athena        Compiled with Athena GUI.
  762. gui_beos        Compiled with BeOs GUI.
  763. gui_mac            Compiled with Macintosh GUI.
  764. gui_motif        Compiled with Motif GUI.
  765. gui_win32        Compiled with MS Windows Win32 GUI.
  766. gui_win32s        idem, and Win32s system being used (Windows 3.1)
  767. gui_running        Vim is running in the GUI, or it will start soon.
  768. insert_expand        Compiled with support for CTRL-X expansion commands in
  769.             Insert mode.
  770. langmap            Compiled with 'langmap' support.
  771. lispindent        Compiled with support for lisp indenting.
  772. mac            Macintosh version of Vim.
  773. mouse            Compiled with support mouse.
  774. mouse_dec        Compiled with support for Dec terminal mouse.
  775. mouse_netterm        Compiled with support for netterm mouse.
  776. mouse_xterm        Compiled with support for xterm mouse.
  777. ole            Compiled with OLE automation support for Win32.
  778. perl            Compiled with Perl interface.
  779. python            Compiled with Python interface.
  780. quickfix        Compiled with |quickfix| support.
  781. rightleft        Compiled with 'rightleft' support.
  782. showcmd            Compiled with 'showcmd' support.
  783. smartindent        Compiled with 'smartindent' support.
  784. sniff            Compiled with SniFF interface support.
  785. syntax            Compiled with syntax highlighting support.
  786. syntax_items        There are active syntax highlighting items for the
  787.             current buffer.
  788. system            Compiled to use system() instead of fork()/exec().
  789. tag_binary        Compiled with binary searching in tags files
  790.             |tag-binary-search|.
  791. tag_old_static        Compiled with support for old static tags
  792.             |tag-old-static|.
  793. tag_any_white        Compiled with support for any white characters in tags
  794.             files |tag-any-white|.
  795. terminfo        Compiled with terminfo instead of termcap.
  796. textobjects        Compiled with support for |text-objects|.
  797. tgetent            Compiled with tgetent support, able to use a termcap
  798.             or terminfo file.
  799. unix            Unix version of Vim.
  800. viminfo            Compiled with viminfo support.
  801. win32            Win32 version of Vim (Windows 95/NT)
  802. writebackup        Compiled with 'writebackup' default on.
  803. xterm_save        Compiled with support for saving and restoring the
  804.             xterm screen.
  805. x11            Compiled with X11 support.
  806.  
  807. ==============================================================================
  808. 5. Commands                        *expression-commands*
  809.  
  810. :let {var-name} = {expr1}                *:let*
  811.             Set internal variable {var-name} to the result of the
  812.             expression {expr1}.  The variable will get the type
  813.             from the {expr}.  if {var-name} didn't exist yet, it
  814.             is created.
  815.  
  816. :let ${env-name} = {expr1}            *:let-environment* *:let-$*
  817.             Set environment variable {env-name} to the result of
  818.             the expression {expr1}.  The type is always String.
  819.  
  820. :let @{reg-name} = {expr1}            *:let-register* *:let-@*
  821.             Write the result of the expression {expr1} in register
  822.             {reg-name}.  {reg-name} must be a single letter, and
  823.             must be the name of a writable register (see
  824.             |registers|).  "@@" can be used for the unnamed
  825.             register.  If the result of {expr1} ends in a <CR> or
  826.             <NL>, the register will be linewise, otherwise it will
  827.             be set to characterwise.
  828.  
  829. :let &{option-name} = {expr1}            *:let-option* *:let-star*
  830.             Set option {option-name} to the result of the
  831.             expression {expr1}.  The type of the option is always
  832.             used.
  833.  
  834.                             *:unlet* *:unl*
  835. :unl[et] {var-name}    Remove the internal variable {var-name}.
  836.  
  837. :if {expr1}                        *:if* *:endif* *:en*
  838. :en[dif]        Execute the commands until the next matching ":else"
  839.             or ":endif" if {expr1} evaluates to non-zero.
  840.  
  841.             From Vim version 4.5 until 5.0, every Ex command in
  842.             between the ":if" and ":endif" is ignored.  These two
  843.             commands were just to allow for future expansions in a
  844.             backwards compatible way.  Nesting was allowed.  Note
  845.             that any ":else" or ":elseif" was ignored, the "else"
  846.             part was not executed either.
  847.  
  848.             You can use this to remain compatible with older
  849.             versions:
  850. >                :if version >= 500
  851. >                :  version-5-specific-commands
  852. >                :endif
  853.  
  854.                             *:else* *:el*
  855. :else            Execute the commands until the next matching ":else"
  856.             or ":endif" if they previously were not being
  857.             executed.
  858.  
  859.                             *:elseif* *:elsei*
  860. :elsei[f] {expr1}    Short for ":else" ":if", with the addition that there
  861.             is no extra ":endif".
  862.  
  863. :wh[ile] {expr1}            *:while* *:endwhile* *:wh* *:endw*
  864. :endw[hile]        Repeat the commands between ":while" and ":endwhile",
  865.             as long as {expr1} evaluates to non-zero.
  866.             When an error is detected from a command inside the
  867.             loop, execution continues after the "endwhile".
  868.  
  869.         NOTE: The ":append" and ":insert" commands don't work properly
  870.         inside a ":while" loop.
  871.  
  872.                             *:continue* *:con*
  873. :con[tinue]        When used inside a ":while", jumps back to the
  874.             ":while".
  875.  
  876.                             *:break* *:brea*
  877. :brea[k]        When used inside a ":while", skips to the command
  878.             after the matching ":endwhile".
  879.  
  880.                             *:ec* *:echo*
  881. :ec[ho] {expr1} ..    Echoes each {expr1}, with a space in between and a
  882.             terminating <EOL>.  Also see |:comment|.
  883.             Example:
  884. >        :echo "the value of 'shell' is" &shell
  885.  
  886.                             *:echon*
  887. :echon {expr1} ..    Echoes each {expr1}, without anything added.  Also see
  888.             |:comment|.
  889.             Example:
  890. >        :echon "the value of 'shell' is " &shell
  891.  
  892.             Note the difference between using ":echo", which is a
  893.             Vim command, and ":!echo", which is an external shell
  894.             command:
  895. >        :!echo %        --> filename
  896.             The arguments of ":!" are expanded, see |:_%|.
  897. >        :!echo "%"        --> filename or "filename"
  898.             Like the previous example.  Whether you see the double
  899.             quotes or not depends on your 'shell'.
  900. >        :echo %            --> nothing
  901.             The '%' is an illegal character in an expression.
  902. >        :echo "%"        --> %
  903.             This just echoes the '%' character.
  904. >        :echo expand("%")    --> filename
  905.             This calls the expand() function to expand the '%'.
  906.  
  907.                             *:echoh* *:echohl*
  908. :echoh[l] {name}    Use the highlight group {name} for the following
  909.             ":echo[n]" commands.  Example:
  910. >        :echohl WarningMsg | echo "Don't panic!" | echohl None
  911.             Don't forget to set the group back to "None",
  912.             otherwise all following echo's will be highlighted.
  913.  
  914.                             *:exe* *:execute*
  915. :exe[cute] {expr1} ..    Executes the string that results from the evaluation
  916.             of {expr1} as an Ex command.  Multiple arguments are
  917.             concatenated, with a space in between.  Examples:
  918. >        :execute "buffer " nextbuf
  919. >        :execute "normal " count . "w"
  920.  
  921.             Execute can be used to append a next command to
  922.             commands that don't accept a '|'.  Example:
  923. >        :execute '!ls' | echo "theend"
  924.  
  925.             Note: The executed string may be any command line, but
  926.             you cannot start or end a "while" or "if" command.
  927.             Thus this is illegal:
  928. >        :execute 'while i > 5'
  929. >        :execute 'echo "test" | break'
  930.  
  931.             It is allowed to have a "while" or "if" command
  932.             completely in the executed string:
  933. >        :execute 'while i < 5 | echo i | let i = i + 1 | endwhile'
  934.  
  935.  
  936.                             *:comment*
  937.             ":execute", ":echo" and ":echon" cannot be followed by
  938.             a comment directly, because they see the '"' as the
  939.             start of a string.  But, you can use '|' followed by a
  940.             comment.  Example:
  941. >        :echo "foo" | "this is a comment
  942.  
  943.  vim:tw=78:ts=8:sw=8:
  944.